﻿
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace WinnerCMS.Data.Mapping
{
    public partial class RoleMap
        : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<WinnerCMS.Model.Role>
    {
        public RoleMap()
        {
            // table
            //ToTable("CMS_Role");

            // keys
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
                
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();
            Property(t => t.RoleName)
                
                .HasMaxLength(50)
                .IsRequired();
            Property(t => t.Remark)
                
                .HasMaxLength(100)
                .IsRequired();
            Property(t => t.Rank)
                
                .IsRequired();
            Property(t => t.IsAdmin)
                
                .IsRequired();

            // Relationships
            HasMany(t => t.Users)
                .WithMany(t => t.Roles);
            HasMany(t => t.Categoryes)
                .WithMany(t => t.Roles);

            //InitializeMapping();
        }
    }
}

